﻿<%@ Page Title="View Customer Page" Language="C#" MasterPageFile="  ~/template/Site.Master" AutoEventWireup="true" CodeBehind="ViewCustomer.aspx.cs" Inherits="EAAdmin.ViewCustomer" %>

<%@ Import Namespace="EA.DTO" %>
<%@ Import Namespace="EA.Common" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <form id="form1" runat="server">
        <div class="page_name">List of Customer</div>
         <div class="error">
            <%                
                String alert = "";
                if (Attributes.ContainsKey("err"))
                {
                    alert = (String)Attributes["err"];
            %>
            <div class="message">
                <div><%=alert%></div>
            </div>
            <%  }
                if (Attributes.ContainsKey("success"))
                {
                    alert = (String)Attributes["success"];
            %>
            <div class="message_alert">
                <div><%=alert%></div>
            </div>
            <%  } %>
        </div>
        <table class="table">
            <tr>
                <th>Id</th>
                <th>Email</th>
                <th>Sellable</th>
                <th>Full Name</th>
                <th>Phone</th>
                <th>Address</th>
                <th>Edit</th>
            </tr>
            <% 
                List<CustomerTO> listCustomer = (List<CustomerTO>)Attributes["listCustomer"]; 
                for (int i = 0; i < listCustomer.Count; i++)
                {  
            %>
            <tr>
                <td><%=listCustomer[i].ID%></td>
                <td><%=listCustomer[i].Email %></td>
                <td><% if (listCustomer[i].Sellable == Constant.SELLABLE)
                       {%>Yes<% }
                       else
                       {%>No<%} %></td>
                <td><%=listCustomer[i].FullName %></td>
                <td><%=listCustomer[i].Phone %></td>
                <td><%=listCustomer[i].Address %></td>
                <td>
                    <a href="/ViewCustomer.aspx?action=Delete&id=<%=listCustomer[i].ID %>" style="margin-right: 5px; float: right">
                        <img src="/public/images/cross.png" />
                    </a>
                    <a href="/EditCustomer.aspx?id=<%=listCustomer[i].ID %>" style="margin-right: 5px; float: right">
                        <img src="/public/images/pencil.png" />
                    </a>
                </td>
            </tr>
            <% } %>
        </table>

        <%
            int total = (Int32)Attributes["totalCustomer"];
            int totalView = Constant.TOTAL_RECORD_VIEW;
            double page = (double)total / (double)totalView;
            if (page > (int)page)
            {
                page = page + 1;
            }
        %>
        <div>
            <div>Page</div>
            <select onchange="location.href='/ViewCustomer.aspx?page='+this.value;">
                <% 
                    for (int i = 1; i < page; i++)
                    { 
                %>
                <option <%= ( ((int)Attributes["page"]) == i ) ? "selected" : "" %> value="<%=i %>">
                    <%=i %>
                </option>
                <%  
                    }
                %>
            </select>
        </div>
    </form>
</asp:Content>
